Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #730 compatibility with web profiler 4 #735

Merged
merged 7 commits into from
Nov 24, 2017

Conversation

ostrolucky
Copy link
Member

@ostrolucky ostrolucky commented Nov 19, 2017

Doctrine profiler does not work in Symfony 4. This issue is completely ignored, so I had to give it a try. I have extended travis matrix to test Symfony 4 and fixed all Symfony 4 test failures.

@ostrolucky ostrolucky force-pushed the feature-730 branch 2 times, most recently from 33849d5 to d77fb48 Compare November 19, 2017 17:49
@ostrolucky ostrolucky force-pushed the feature-730 branch 6 times, most recently from a58951d to b0fa88d Compare November 20, 2017 01:42
"symfony/web-profiler-bundle": "~2.7|~3.0|~4.0"
},
"conflict": {
"symfony/http-foundation": "<2.6"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db.html.twig uses request.query.getBoolean(). ParameterBag#getBoolean has been introduced with 2.6

@@ -29,7 +29,7 @@
"symfony/console": "~2.7|~3.0|~4.0",
"symfony/dependency-injection": "~2.7|~3.0|~4.0",
"doctrine/dbal": "^2.5.12",
"jdorn/sql-formatter": "~1.1",
"jdorn/sql-formatter": "^1.2.16",
Copy link
Member Author

@ostrolucky ostrolucky Nov 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DoctrineExtension uses SqlFormatter::$variable_attributes, introduced with 1.2.16

@@ -39,9 +39,13 @@
"symfony/validator": "~2.7|~3.0|~4.0",
"symfony/property-info": "~2.8|~3.0|~4.0",
"symfony/phpunit-bridge": "~2.7|~3.0|~4.0",
"twig/twig": "~1.12|~2.0",
"twig/twig": "~1.26|~2.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Increased to be able to call Twig_Environment::addRuntimeLoader in tests. Notice it's require-dev section

.travis.yml Outdated

env:
global:
- deps=no

before_install:
- composer self-update
- if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update symfony/symfony:${SYMFONY_VERSION}; fi;
- if [ "$SYMFONY_VERSION" != "" ]; then jq "(.require, .\"require-dev\")|=(with_entries(if .key|test(\"^symfony/\") then .value|=\"${SYMFONY_VERSION}\" else . end))" composer.json|ex -sc 'wq!composer.json' /dev/stdin; fi;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old approach replaced to be able to keep paths used in tests in ../vendor/symfony/{component} format, instead of introducing switches in tests to determine if ../vendor/symfony/symfony/{component} exists. Simple regex not used to keep conflicts section without change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much simpler: composer require symfony/lts (be careful, versions there are just 2 and 3, not 2.8 and 3.4)

Copy link
Member Author

@ostrolucky ostrolucky Nov 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, though you already said disadvantages yourself. I would like to keep ability to pick exact symfony version. Other then that, this snippet will provide good example/base for future modifications of composer.json.

foreach ($this->data['queries'] as &$queries) {
foreach ($queries as &$query) {
// HttpKernel < 3.2 compatibility layer
if (!method_exists($this, 'cloneVar')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't both foreach be inside that if ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed

@mikeSimonson mikeSimonson requested a review from stof November 20, 2017 23:57
.travis.yml Outdated
- php: 5.6
env: SYMFONY_VERSION="2.8.*"
- php: 7.0
env: SYMFONY_VERSION="3.2.*"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't had it. 3.2 is unmaintained

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly true, end of support is in January. Until then we need to make sure it works. If you notice, there are BC layers introduced in my patch and I would like them to get tested.

.travis.yml Outdated
- php: 7.1
env: SYMFONY_VERSION="3.4.*@beta"
- php: 7.2
env: SYMFONY_VERSION="4.0.*@beta"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 for that. This is already covered by the deps=dev job. I'm only adding version-specific jobs for LTS versions (I don't want to update this config file every 6 months to change the versions, too painful)

Copy link
Member Author

@ostrolucky ostrolucky Nov 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which deps=dev? The one for PHP 5.6, which didn't allow to install Symfony 4? The one which was allowed to fail anyway? We can't afford for this bundle to stay incompatible with next Symfony version and figure it out only at RC phase again. These constraints should be set in the way it's clear that something is wrong when tests fail, but on the other side aren't supposed to be expected to fail randomly, which would be the case with dev dependencies. I suggest to have matrix for latest dev=alpha then. That's when failures are starting to be unwanted. But either case, if this line is removed, it means CI won't test against Symfony 4 once Symfony 4.1 is released. I think we should test against each supported minor version though. Thoughts?

@@ -47,6 +47,7 @@ public function process(ContainerBuilder $container)
}

$resolver = $container->findDefinition($resolverId);
$resolver->setPublic(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be better to use a ServiceLocator (by changing the lazy-loading listener resolver) rather than forcing to use public services

Copy link
Member Author

@ostrolucky ostrolucky Nov 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what do you mean, although I don't want to change behaviour. Tests expect this service to be public, meaning having it directly accessible from container. Making it otherwise would be BC break. I have done this change only to fix tests. I think it was concretely this one

$this->assertTrue($container->getDefinition('doctrine.orm.em1_entity_listener_resolver')->isPublic());

{% endfor %}
</tbody>
</table>
{% endmacro %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add the final EOL

$output = str_replace(["\e[37m", "\e[0m", "\e[32;1m", "\e[34;1m"], "", $output);
$this->assertContains("SELECT * FROM foo WHERE bar IN ('foo', 'bar');", $output);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing final EOL

use Symfony\Component\HttpKernel\Profiler\Profile;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class ProfilerTest extends \PHPUnit\Framework\TestCase
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a use statement

@weaverryan
Copy link
Contributor

Hey guys! Do we need any more changes on this? I'm tracking to make sure we get a release and tag by next week.

@ostrolucky
Copy link
Member Author

It's finished from my POV

@ostrolucky
Copy link
Member Author

ostrolucky commented Nov 24, 2017

Let's please try to do the merge during this Symfony RC phase, so analogous patch for Doctrine bridge I will create can make it into 3.4 which will allow us to drop this workaround https://github.com/ostrolucky/DoctrineBundle/blob/b1e881aacb1af71293ceca13da852c01d9fc1afe/DataCollector/DoctrineDataCollector.php#L140-L149 when Symfony 2.* is EOL. If we won't make it, that workaround might have to stay there during whole life cycle of Symfony 3.4.

@weaverryan
Copy link
Contributor

@ostrolucky Unless it's a pretty serious/obvious bug fix, nothing at this point will make it into 3.4. So, I think that workaround will need to stay. But, no big deal.

But yes, since this is broken in Symfony 4, I'd love to see a quick merge + tag so that (if there are any more issues), we can find them.

@mikeSimonson mikeSimonson merged commit eb6e4fb into doctrine:master Nov 24, 2017
@mikeSimonson mikeSimonson self-assigned this Nov 24, 2017
@weaverryan
Copy link
Contributor

Thanks @mikeSimonson! I already see a new 1.8.0 tag... but I think this isn't included in it? Is that correct? Could we create a 1.8.1 with this fix?

@mikeSimonson mikeSimonson modified the milestones: 1.7.1, 1.8.1 Nov 25, 2017
@mikeSimonson
Copy link
Contributor

@weaverryan done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants